package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.Shipment;
import top.tsyz.service.IShipmentService;

import java.util.List;

/**
 * ShipmentController控制器
 */
@RestController
@RequestMapping("/api/shipments")
@Api(tags = "Shipment管理接口")
public class ShipmentController {

    @Autowired
    private IShipmentService ishipmentservice;

    @GetMapping("/list")
    @ApiOperation("获取所有Shipment")
    public List<Shipment> list() {
        return ishipmentservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取Shipment")
    public Shipment getById(@PathVariable Long id) {
        return ishipmentservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增Shipment")
    public boolean save(@RequestBody Shipment shipment) {
        return ishipmentservice.save(shipment);
    }

    @PutMapping
    @ApiOperation("更新Shipment")
    public boolean update(@RequestBody Shipment shipment) {
        return ishipmentservice.updateById(shipment);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除Shipment")
    public boolean delete(@PathVariable Long id) {
        return ishipmentservice.removeById(id);
    }
}
